package SSP;

import java.util.*;
import javax.mail.*;
import javax.mail.internet.*;

public class SendEmail
{

    public SendEmail()
    {
    }

    public void mailIt(String recipient, String sender, String subjecttext, String mailtext)
    {
        Properties properties = new Properties();
        properties.put("mail.smtp.host", "3.72.79.252");
        Session session = Session.getDefaultInstance(properties, null);
        try
        {
            MimeMessage mimemessage = new MimeMessage(session);
            mimemessage.setFrom(new InternetAddress(sender));
            InternetAddress ainternetaddress[] = {
                new InternetAddress(recipient)
            };
            mimemessage.setRecipients(javax.mail.Message.RecipientType.TO, ainternetaddress);
            mimemessage.setSubject(subjecttext);
            mimemessage.setSentDate(new Date());
            MimeBodyPart mimebodypart = new MimeBodyPart();
            mimebodypart.setContent(mailtext, "text/html");
            MimeMultipart mimemultipart = new MimeMultipart();
            mimemultipart.addBodyPart(mimebodypart);
            mimemessage.setContent(mimemultipart);
            Transport.send(mimemessage);
        }
        catch(MessagingException messagingexception)
        {
            messagingexception.printStackTrace(System.out);
        }
    }
}
